import java.io.*;
import javax.swing.*;
import javax.swing.JOptionPane;
public class Data {
	
	public static void InitializeData(){
		String pathToDF = new String();
		File ini = new File("config.ini");
		try{
			if(ini.exists()){
				BufferedReader br = new BufferedReader(new FileReader(ini));
				String s = new String();
				s = br.readLine();
				if(s == null){
					FileWriter fw = new FileWriter(ini);
					s = (String)JOptionPane.showInputDialog("Please enter the Path to the DF directory");
					fw.write("path="+s);
					fw.flush();
					fw.close();
					br.close();
					InitializeData();
				}
				else if(s.substring(0,5).equals("path=")){
					s = s.substring(5);
					pathToDF = s;
					br.close();
				}
				else{
 					br.close();
					ini.delete();
					Data.InitializeData();
				}
			}		
			else{
				FileWriter fw = new FileWriter(ini);
				String s = (String)JOptionPane.showInputDialog("Please enter the Path to the DF directory");
				fw.write("path=" + s);
				fw.flush();
				fw.close();
				InitializeData();
			}
		}
		catch (IOException e){
			e.printStackTrace();
		}
		File path = new File(pathToDF);
		if(!path.exists() && !path.isDirectory()){
			JOptionPane.showConfirmDialog(null, path + " does not exist.");
			ini.delete();
			Data.InitializeData();
		}
	}	
}
